package cn.edu.scau.cmi.yanghaorui.client;

import java.util.ArrayList;
import java.util.Scanner;

import cn.edu.scau.cmi.yanghaorui.combination.consistent.ConsistentOrangization;
import cn.edu.scau.cmi.yanghaorui.combination.consistent.ConsistentPersonal;
import cn.edu.scau.cmi.yanghaorui.combination.consistent.ConsistentTeam;
import cn.edu.scau.cmi.yanghaorui.combination.safe.SafeOrangization;
import cn.edu.scau.cmi.yanghaorui.combination.safe.SafePersonal;
import cn.edu.scau.cmi.yanghaorui.combination.safe.SafeTeam;

public class CombinationConsistentClient {

	public static int team_num;
	public static ArrayList <ConsistentOrangization> sum;
	public static ArrayList <ConsistentTeam> sum2;
	public static ArrayList <ConsistentPersonal> sum3;

	public static void main(String[] args) {
		team_num=0;
		ArrayList <ConsistentOrangization> sa=new ArrayList <ConsistentOrangization>();
		ArrayList <ConsistentOrangization> sa2=new ArrayList <ConsistentOrangization>();
		sum=new ArrayList <ConsistentOrangization>();
		sum2=new ArrayList <ConsistentTeam>(); 
		sum3=new ArrayList <ConsistentPersonal>();
		ConsistentTeam t=new ConsistentTeam();
		sum2.add(t);
		System.out.println("已有根组织团队1");
		/*SafeTeam t2=new SafeTeam();
		SafeTeam t3=new SafeTeam();
		SafeTeam t4=new SafeTeam();
		SafeTeam t5=new SafeTeam();
		SafePersonal s=new SafePersonal("张三");
		SafePersonal s2=new SafePersonal("李四");
		SafePersonal s3=new SafePersonal("王五");
		SafePersonal s4=new SafePersonal("赵六");
		t.add(t2);
		t.add(t3);*/
		//t.add(t5);
		/*t.add(s);
		t2.add(s2);
		t2.add(s3);
		t3.add(t4);
		t4.add(s4);*/
		sa2=t.getOrg_list();
		if(t.getOrg_list().size()!=0&&t.getOrg_list()!=null) {
			t.say2(sa2,sa);
		}
		/*for(int u=0;u<5;u++) {
			CombinationSafeClient.change();
		}*/
		CombinationConsistentClient.change();
		CombinationConsistentClient.change();
		
		sa2=t.getOrg_list();
		if(t.getOrg_list().size()!=0&&t.getOrg_list()!=null) {
			t.say2(sa2,sa);
		}
		
		

	}
	public static void change() {
		System.out.println("请添加成员或组织");
		Scanner scanner = new Scanner(System.in);  
		String brandKind = scanner.next();  
		String people,orgation,orgation2;
		//AbstractFactory factory=null;
		switch(brandKind){
		case "添加成员": System.out.println("请输入成员名");
		                Scanner scanner2 = new Scanner(System.in);  
		                String peopleKind = scanner.next(); 
		                people=peopleKind;
		                
		                ConsistentPersonal s=new  ConsistentPersonal(people);
		                sum.add(s);
		                sum3.add(s);
		                
		               System.out.println("请输入成员所属组织");
		               Scanner scanner3 = new Scanner(System.in);  
		                String orgKind = scanner.next(); 
		                orgation=orgKind;
		                
		                for( ConsistentTeam ss:sum2){
		                	if((ss.sym_name).equals(orgation)) {
		                		ss.add(( ConsistentOrangization)s);
		                		System.out.println("添加成员成功！！！");
		                		break;
		                	}
		                }
		                
		               break;
		case "添加组织": //System.out.println("请输入组织名");
                    // Scanner scanner4 = new Scanner(System.in);  
                    //String org1 = scanner.next(); 
                   // orgation=org1;
                   System.out.println("请输入组织的上级组织");
                  Scanner scanner5 = new Scanner(System.in);  
                   String org2 = scanner.next(); 
                    orgation2=org2;
                    
                    int sym=0;
                    for( ConsistentPersonal ss:sum3){
                    	//System.out.println(ss.sym_name);
                    	//System.out.println(orgation2);
	                	if((ss.sym_name).equals(orgation2)) {
	                		//ss.add((SafeOrangization)st);
	                		//System.out.println("666");
	                		ss.add();
	                		//System.out.println("编译错误！成员不可再添加成员或组织！");
	                		sym=1;
	                		break;
	                	}
	                }
                    if(sym==1) {
                    	break;
                    }
                    
                    
                    
                    ConsistentTeam st=new  ConsistentTeam();
                    for(ConsistentTeam ss:sum2){
                    	//System.out.println(ss.sym_name);
                    	//System.out.println(orgation2);
	                	if((ss.sym_name).equals(orgation2)) {
	                		ss.add((ConsistentOrangization)st);
	                		System.out.println("添加组织成功！！！");
	                		//System.out.println("666");
	                		break;
	                	}
	                }
                    sum2.add(st);
                    
			           break;
		//case "aonong": break;
		default:System.out.println("sorry, your input is not correct");
		
		}
	}


}
